home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!smeyers
- From: smeyers@netcom.com (Scott Meyers)
- Subject: Re: Placement-new with virtual function problem on HP
- Message-ID: <smeyersDMGrHG.6D9@netcom.com>
- Organization: Netcom Online Communications Services (408-241-9760 login: guest)
- References: <4faium$2c6@hermes.oc.com> <00001a81+00009ca3@msn.com>
- Date: Thu, 8 Feb 1996 15:39:16 GMT
- Sender: smeyers@netcom19.netcom.com
-
- In article <00001a81+00009ca3@msn.com> Tendrils@msn.com (kelvin ) writes:
- | Your overridden new may be hiding the global new .... which explain
- | why it works when you revert back .... try this (from effective c++
- | by Scott Meyers)...
- |
- | In the test class, add this function
- |
- | void *operator new(size_t size)
- | { return ::new char[size];}
-
- Better yet, write this function the way I *should* have written it in
- Effective C++:
-
- void * operator new(size_t size)
- { return ::operator new(size); }
-
- On most machines, the two implementations will behave the same, but it is
- possible that the former will fail to satisfy alignment restrictions and
- the latter will not.
-
- For more information on the difference between "new char[...]" and a call
- to "operator new," you might check out Item 8 in my new book, "More
- Effective C++."
-
- Scott
-
-
-
-